﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Models;
using System.Data;

namespace DAL
{
   public  class KechengandZhangjieDAL
    {
        /// <summary>
        /// 课程表和章节表两表查询
        /// </summary>
        /// <returns></returns>
        public static List<KechengandZhangjie> Selecttwo()
        {
            string sql = "select k.KeChengID,k.KeChengName,SUM(ZhangjieCount) he  from KeCheng k,Zhangjie z where k.KeChengID=z.KeChengID group by k.KeChengID, k.KeChengName ";

            DataTable dt = DBHelper.Instance().GetDataTableBySql(sql);
            List<KechengandZhangjie> list = new List<KechengandZhangjie>();
            foreach (DataRow item in dt.Rows)
            {
                KechengandZhangjie model = new KechengandZhangjie();
                model.KeChengID = Convert.ToInt32(item["KeChengID"]);
                //model.KeChengImages = item["KeChengImages"].ToString();
                model.KeChengName = item["KeChengName"].ToString();
                //model.KeChengPrice = Convert.ToDecimal(item["KeChengPrice"]);
                //model.KeChengTuanjia = Convert.ToDecimal(item["KeChengTuanjia"]);
                //model.KeChengTypeID = Convert.ToInt32(item["KeChengTypeID"]);
                model.He = Convert.ToInt32(item["he"]);
                //model.ZhangjieID = Convert.ToInt32(item["ZhangjieID"]);
                //model.ZID = Convert.ToInt32(item["ZID"]);
                list.Add(model);
            }
            return list;
        }
    }
}
